package cn.edu.lzu.service.impl;

import cn.edu.lzu.common.assist.DataPage;
import cn.edu.lzu.dao.PermissionMapper;
import cn.edu.lzu.entity.Permission;
import cn.edu.lzu.service.PermissionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @PackageName: cn.edu.lzu.service.impl
 * @ClassName: PermissionServiceImpl
 * @Description: TODO
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2020/5/5 17:59
 * @Version: 1.0
 */
@Service
@Transactional
public class PermissionServiceImpl implements PermissionService {
    @Resource
    private PermissionMapper permissionMapper;


    @Override
    public DataPage getPermissions() {
        List<Permission> permissionList=permissionMapper.selPermissions();
        DataPage dataPage=new DataPage();
        dataPage.setData(permissionList);
        dataPage.setTotalCount(permissionList.size());
        dataPage.setCode(0);
        dataPage.setMsg("成功");
        return dataPage;
    }

    @Override
    public List<Permission> getPermissionsByRoleId(long unitId, int roleId) {
        List<Permission> permissionList=permissionMapper.selPermissionsByRoleId(roleId, unitId);
        return permissionList;
    }
}
